/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Vistas.java
 *
 * Created on 23-dic-2011, 21:31:09
 */
package AplicacionMVC;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.mail.MessagingException;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import java.util.Map;
import javax.swing.JComboBox;
import funciones.*;
import funciones.TipoFormulario.Tipo;
import java.awt.Color;
import java.awt.Component;
import java.awt.event.MouseAdapter;
import java.util.HashMap;
import javax.swing.DefaultListCellRenderer;
import javax.swing.DefaultListModel;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.ListModel;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Jesus Ruiz Oliva
 */
public class Vistas extends javax.swing.JPanel {
      
    /** Creates new form Vistas */
    public Vistas() {
        histograma = new Histogram();
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        panel1 = new javax.swing.JPanel();
        etiqueta1 = new javax.swing.JLabel();
        etiqueta2 = new javax.swing.JLabel();
        etiqueta3 = new javax.swing.JLabel();
        pass = new javax.swing.JPasswordField();
        user = new javax.swing.JTextField();
        Button1 = new javax.swing.JButton();
        errorLogin = new javax.swing.JLabel();
        buttonExit = new javax.swing.JButton();
        panel2 = new javax.swing.JPanel();
        panelMedico = new javax.swing.JPanel();
        fotoMedico = new javax.swing.JLabel();
        nombreMedico = new javax.swing.JLabel();
        consultaMedico = new javax.swing.JLabel();
        emailMedico = new javax.swing.JLabel();
        telefonoMedico = new javax.swing.JLabel();
        Button5 = new javax.swing.JButton();
        Button3 = new javax.swing.JButton();
        buttonLogout = new javax.swing.JButton();
        panelCitas = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        listModelCitas = new DefaultListModel();
        jList1 = new javax.swing.JList(listModelCitas);
        panel4 = new javax.swing.JPanel();
        panel5 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        listModel = new DefaultListModel();
        jList2 = new javax.swing.JList(listModel);
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        jButton3 = new javax.swing.JButton();
        panelFormularioGenerico = new javax.swing.JScrollPane();
        panel7 = new javax.swing.JPanel();
        button_Formulario_Cancelar = new javax.swing.JButton();
        button_Formulario_Guardar = new javax.swing.JButton();
        PanelDatosPaciente1 = new javax.swing.JPanel();
        DNIPaciente = new javax.swing.JLabel();
        NSSPaciente = new javax.swing.JLabel();
        NombrePaciente = new javax.swing.JLabel();
        DireccionPaciente = new javax.swing.JLabel();
        TelefonoPaciente = new javax.swing.JLabel();
        FotoPaciente1 = new javax.swing.JLabel();
        NacimientoPaciente = new javax.swing.JLabel();
        EmailPaciente = new javax.swing.JLabel();
        TratamientosActuales = new javax.swing.JPanel();
        jScrollPane5 = new javax.swing.JScrollPane();
        tableModelTratamientosActuales = new DefaultTableModel();
        jTableTratamientosActuales = new javax.swing.JTable(tableModelTratamientosActuales);
        jLabelTratamiento = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jScrollPane9 = new javax.swing.JScrollPane();
        tableModelMedicinas = new DefaultTableModel();
        jTableMedicinas = new javax.swing.JTable(tableModelMedicinas);
        jScrollPane10 = new javax.swing.JScrollPane();
        tableModelCuras = new DefaultTableModel();
        jTableCuras = new javax.swing.JTable(tableModelCuras);
        jScrollPane11 = new javax.swing.JScrollPane();
        tableModelOtros = new DefaultTableModel();
        jTableOtros = new javax.swing.JTable(tableModelOtros);
        jLabel5 = new javax.swing.JLabel();
        jButtonHistorial = new javax.swing.JButton();
        jButtonPruebas = new javax.swing.JButton();
        buttonFotoCam = new javax.swing.JButton();
        jButtonImprimir = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        jLabelComentario = new javax.swing.JLabel();
        jScrollPane4 = new javax.swing.JScrollPane();
        jTextAreaDiagnostico = new javax.swing.JTextArea();
        jScrollPane7 = new javax.swing.JScrollPane();
        jTextAreaComentario = new javax.swing.JTextArea();
        jScrollPane8 = new javax.swing.JScrollPane();
        jTextAreaExamenPreliminar = new javax.swing.JTextArea();
        jLabelAlergias = new javax.swing.JLabel();
        jScrollPane12 = new javax.swing.JScrollPane();
        jTableAlergias = new javax.swing.JTable();
        jLabelDiscapacidades = new javax.swing.JLabel();
        jScrollPane13 = new javax.swing.JScrollPane();
        jTableDiscapacidades = new javax.swing.JTable();
        jButtonCambiarFormulario = new javax.swing.JButton();
        panelMotivo = new javax.swing.JPanel();
        buttonMotivoAtras = new javax.swing.JButton();
        buttonMotivoGuardar = new javax.swing.JButton();
        PanelDatosCita = new javax.swing.JPanel();
        DNIPacienteMotivo = new javax.swing.JLabel();
        NSSPacienteMotivo = new javax.swing.JLabel();
        MotivoPacienteMotivo = new javax.swing.JLabel();
        FotoPacienteMotivo = new javax.swing.JLabel();
        FechaPacienteMotivo = new javax.swing.JLabel();
        buttonMotivoCambiar = new javax.swing.JButton();
        panelCambiarMotivo = new javax.swing.JPanel();
        buttonCambiarMotivoAtras = new javax.swing.JButton();
        jScrollPane6 = new javax.swing.JScrollPane();
        listModelCambiarMotivo = new DefaultListModel();
        jListCambiarMotivo = new javax.swing.JList(listModelCambiarMotivo);
        panelHistorial = new javax.swing.JPanel();
        tabHistorial = new javax.swing.JTabbedPane();
        scrollAlergias = new javax.swing.JScrollPane();
        listModelAlergias = new DefaultListModel();
        jListAlergias = new javax.swing.JList(listModelAlergias);
        scrollCuras = new javax.swing.JScrollPane();

        setLayout(new java.awt.CardLayout());

        etiqueta1.setFont(new java.awt.Font("Times New Roman", 1, 18));
        etiqueta1.setText("Iniciar Sesion");

        etiqueta2.setText("Usuario");

        etiqueta3.setText("Contraseña");

        pass.setText("emilio");

        user.setText("emperezsanchez@gmail.com");
        user.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                userActionPerformed(evt);
            }
        });

        Button1.setText("Aceptar");

        errorLogin.setForeground(new java.awt.Color(255, 51, 51));

        buttonExit.setText("Salir");

        javax.swing.GroupLayout panel1Layout = new javax.swing.GroupLayout(panel1);
        panel1.setLayout(panel1Layout);
        panel1Layout.setHorizontalGroup(
            panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel1Layout.createSequentialGroup()
                .addGap(799, 799, 799)
                .addComponent(errorLogin)
                .addContainerGap(2012, Short.MAX_VALUE))
            .addGroup(panel1Layout.createSequentialGroup()
                .addGap(263, 263, 263)
                .addGroup(panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panel1Layout.createSequentialGroup()
                        .addGroup(panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(etiqueta3, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(etiqueta2, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(29, 29, 29)
                        .addGroup(panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(pass)
                            .addComponent(user, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addComponent(Button1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(buttonExit))
                    .addGroup(panel1Layout.createSequentialGroup()
                        .addGap(92, 92, 92)
                        .addComponent(etiqueta1, javax.swing.GroupLayout.DEFAULT_SIZE, 576, Short.MAX_VALUE)
                        .addGap(222, 222, 222)))
                .addGap(1658, 1658, 1658))
        );
        panel1Layout.setVerticalGroup(
            panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel1Layout.createSequentialGroup()
                .addGap(228, 228, 228)
                .addComponent(errorLogin)
                .addGap(29, 29, 29)
                .addComponent(etiqueta1)
                .addGap(52, 52, 52)
                .addGroup(panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(etiqueta2)
                    .addComponent(user, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(44, 44, 44)
                .addGroup(panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(etiqueta3)
                    .addComponent(pass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Button1)
                    .addComponent(buttonExit))
                .addContainerGap(1107, Short.MAX_VALUE))
        );

        add(panel1, "card2");

        panelMedico.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Datos personales", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Times New Roman", 0, 18), new java.awt.Color(0, 0, 0))); // NOI18N

        fotoMedico.setText("Foto");

        nombreMedico.setText("Nombre");

        consultaMedico.setText("Email");

        emailMedico.setText("Consulta");

        telefonoMedico.setText("Telefono");

        Button5.setText("Correo");

        Button3.setText("Estadístico");

        javax.swing.GroupLayout panelMedicoLayout = new javax.swing.GroupLayout(panelMedico);
        panelMedico.setLayout(panelMedicoLayout);
        panelMedicoLayout.setHorizontalGroup(
            panelMedicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelMedicoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(consultaMedico)
                .addContainerGap(483, Short.MAX_VALUE))
            .addGroup(panelMedicoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(nombreMedico)
                .addContainerGap(470, Short.MAX_VALUE))
            .addGroup(panelMedicoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(emailMedico)
                .addContainerGap(465, Short.MAX_VALUE))
            .addGroup(panelMedicoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(telefonoMedico)
                .addContainerGap(465, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelMedicoLayout.createSequentialGroup()
                .addContainerGap(449, Short.MAX_VALUE)
                .addComponent(fotoMedico)
                .addGap(46, 46, 46))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelMedicoLayout.createSequentialGroup()
                .addContainerGap(353, Short.MAX_VALUE)
                .addComponent(Button5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(Button3)
                .addContainerGap())
        );
        panelMedicoLayout.setVerticalGroup(
            panelMedicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelMedicoLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(fotoMedico)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(nombreMedico)
                .addGap(28, 28, 28)
                .addComponent(consultaMedico)
                .addGap(23, 23, 23)
                .addComponent(emailMedico)
                .addGap(26, 26, 26)
                .addComponent(telefonoMedico)
                .addGap(18, 18, 18)
                .addGroup(panelMedicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Button5)
                    .addComponent(Button3))
                .addContainerGap())
        );

        buttonLogout.setText("Cerrar cesión");

        panelCitas.setBorder(javax.swing.BorderFactory.createTitledBorder("Citas"));

        jList1.setBackground(new java.awt.Color(240, 240, 240));
        jList1.setCellRenderer(new DefaultListCellRenderer(){
            @Override
            public Component getListCellRendererComponent(JList list, Object value,
                int index,boolean isSelected, boolean cellHasFocus) {
                PacienteCita paciente = (PacienteCita)value;
                setText("Nombre: " + paciente.getNombre()+ " DNI: " + paciente.getDNI());

                if (isSelected) {
                    setBackground(Color.LIGHT_GRAY);
                }
                else{
                    if (paciente.getEstaAtendido())
                    setBackground(Color.GRAY);
                    else
                    setBackground(Color.WHITE);
                }
                return this;

            }
        });
        jList1.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane2.setViewportView(jList1);

        javax.swing.GroupLayout panelCitasLayout = new javax.swing.GroupLayout(panelCitas);
        panelCitas.setLayout(panelCitasLayout);
        panelCitasLayout.setHorizontalGroup(
            panelCitasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelCitasLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 478, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        panelCitasLayout.setVerticalGroup(
            panelCitasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelCitasLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 207, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout panel2Layout = new javax.swing.GroupLayout(panel2);
        panel2.setLayout(panel2Layout);
        panel2Layout.setHorizontalGroup(
            panel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel2Layout.createSequentialGroup()
                .addGroup(panel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(panelMedico, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(63, 63, 63)
                        .addComponent(panelCitas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(panel2Layout.createSequentialGroup()
                        .addGap(30, 30, 30)
                        .addComponent(buttonLogout)))
                .addContainerGap(1699, Short.MAX_VALUE))
        );
        panel2Layout.setVerticalGroup(
            panel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel2Layout.createSequentialGroup()
                .addGap(32, 32, 32)
                .addGroup(panel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(panelCitas, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(panelMedico, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(24, 24, 24)
                .addComponent(buttonLogout)
                .addGap(1194, 1194, 1194))
        );

        add(panel2, "card3");

        panel4.setLayout(new java.awt.GridLayout(1, 0));

        //funciones.Histogram h = new funciones.Histogram();
        panel4.add(histograma);

        add(panel4, "card5");

        jButton1.setText("<");

        jButton2.setText(">");

        jList2.setCellRenderer(new DefaultListCellRenderer(){
            @Override
            public Component getListCellRendererComponent(JList list, Object value,
                int index,boolean isSelected, boolean cellHasFocus) {
                Mensaje mensaje=(Mensaje)value;
                setText(mensaje.getMensaje());
                setIcon(mensaje.getImage());
                if (isSelected)
                setBackground(Color.LIGHT_GRAY);
                else
                setBackground(Color.WHITE);
                return this;
            }
        });
        jScrollPane3.setViewportView(jList2);

        jTextArea1.setColumns(20);
        jTextArea1.setRows(5);
        jScrollPane1.setViewportView(jTextArea1);

        jButton3.setText("Atras");

        javax.swing.GroupLayout panel5Layout = new javax.swing.GroupLayout(panel5);
        panel5.setLayout(panel5Layout);
        panel5Layout.setHorizontalGroup(
            panel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panel5Layout.createSequentialGroup()
                .addGap(37, 37, 37)
                .addGroup(panel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jButton3)
                    .addGroup(panel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(panel5Layout.createSequentialGroup()
                            .addComponent(jButton1)
                            .addGap(18, 18, 18)
                            .addComponent(jButton2))
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, panel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 1120, Short.MAX_VALUE))))
                .addGap(1654, 1654, 1654))
        );
        panel5Layout.setVerticalGroup(
            panel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel5Layout.createSequentialGroup()
                .addGap(36, 36, 36)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 252, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(panel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton2)
                    .addComponent(jButton1))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 235, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(60, 60, 60)
                .addComponent(jButton3)
                .addContainerGap(860, Short.MAX_VALUE))
        );

        add(panel5, "card6");

        button_Formulario_Cancelar.setText("Cancelar");

        button_Formulario_Guardar.setText("Guardar");

        PanelDatosPaciente1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Datos Paciente", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Times New Roman", 0, 18))); // NOI18N

        DNIPaciente.setText("DNI");

        NSSPaciente.setText("NSS");

        NombrePaciente.setText("Nombre");

        DireccionPaciente.setText("Dirección");

        TelefonoPaciente.setText("Teléfono");

        NacimientoPaciente.setText("Nacimiento");

        EmailPaciente.setText("Email");

        javax.swing.GroupLayout PanelDatosPaciente1Layout = new javax.swing.GroupLayout(PanelDatosPaciente1);
        PanelDatosPaciente1.setLayout(PanelDatosPaciente1Layout);
        PanelDatosPaciente1Layout.setHorizontalGroup(
            PanelDatosPaciente1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PanelDatosPaciente1Layout.createSequentialGroup()
                .addGroup(PanelDatosPaciente1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(PanelDatosPaciente1Layout.createSequentialGroup()
                        .addGroup(PanelDatosPaciente1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(DNIPaciente)
                            .addComponent(NSSPaciente)
                            .addComponent(NombrePaciente))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 140, Short.MAX_VALUE)
                        .addGroup(PanelDatosPaciente1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(TelefonoPaciente)
                            .addComponent(EmailPaciente)
                            .addComponent(NacimientoPaciente))
                        .addGap(70, 70, 70))
                    .addGroup(PanelDatosPaciente1Layout.createSequentialGroup()
                        .addComponent(DireccionPaciente)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                .addComponent(FotoPaciente1, javax.swing.GroupLayout.PREFERRED_SIZE, 183, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        PanelDatosPaciente1Layout.setVerticalGroup(
            PanelDatosPaciente1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(FotoPaciente1, javax.swing.GroupLayout.DEFAULT_SIZE, 261, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PanelDatosPaciente1Layout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addGroup(PanelDatosPaciente1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(DNIPaciente)
                    .addComponent(TelefonoPaciente))
                .addGap(18, 18, 18)
                .addGroup(PanelDatosPaciente1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(EmailPaciente, javax.swing.GroupLayout.DEFAULT_SIZE, 34, Short.MAX_VALUE)
                    .addComponent(NSSPaciente))
                .addGap(14, 14, 14)
                .addGroup(PanelDatosPaciente1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(NombrePaciente)
                    .addComponent(NacimientoPaciente))
                .addGap(18, 18, 18)
                .addComponent(DireccionPaciente)
                .addGap(99, 99, 99))
        );

        TratamientosActuales.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Tratamientos Actuales", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Times New Roman", 0, 18))); // NOI18N
        TratamientosActuales.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        jTableTratamientosActuales.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null}
            },
            new String [] {
                "Tipo", "Nombre", "Inicio", "Fin", "Frecuencia", "Cancelado", "Motivo Cancelacion"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Integer.class, java.lang.Boolean.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane5.setViewportView(jTableTratamientosActuales);

        javax.swing.GroupLayout TratamientosActualesLayout = new javax.swing.GroupLayout(TratamientosActuales);
        TratamientosActuales.setLayout(TratamientosActualesLayout);
        TratamientosActualesLayout.setHorizontalGroup(
            TratamientosActualesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(TratamientosActualesLayout.createSequentialGroup()
                .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 592, Short.MAX_VALUE)
                .addGap(20, 20, 20))
        );
        TratamientosActualesLayout.setVerticalGroup(
            TratamientosActualesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(TratamientosActualesLayout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(135, Short.MAX_VALUE))
        );

        jLabelTratamiento.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabelTratamiento.setText("Tratamientos");

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel4.setText("Examen Preliminar");

        jTableMedicinas.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"Diacortin 1mg", "1/1/1", "2/1/1", "1440"},
                {"Casdf 2mg", "1/1/1", "2/1/1", null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Medicina", "Inicio", "Fin", "Frecuencia"
            }
        ));
        jScrollPane9.setViewportView(jTableMedicinas);

        jTableCuras.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"Andar un poquito", "1/1/1", "2/1/1", "1440"},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Curas", "Inicio", "Fin", "Frecuencia"
            }
        ));
        jScrollPane10.setViewportView(jTableCuras);

        jTableOtros.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"Andar un poquito", "1/1/1", "2/1/1", "1440"},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Otros", "Inicio", "Fin", "Frecuencia"
            }
        ));
        jScrollPane11.setViewportView(jTableOtros);

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 18));
        jLabel5.setText("Formulario: Genérico");

        jButtonHistorial.setText("Historial");
        jButtonHistorial.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonHistorialActionPerformed(evt);
            }
        });

        jButtonPruebas.setText("Solicitar Prueba");
        jButtonPruebas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonPruebasActionPerformed(evt);
            }
        });

        buttonFotoCam.setText("Foto con Cam");

        jButtonImprimir.setText("Imprimir");

        jLabel6.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel6.setText("Diagnostico");

        jLabelComentario.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabelComentario.setText("Comentarios");

        jTextAreaDiagnostico.setColumns(20);
        jTextAreaDiagnostico.setRows(5);
        jScrollPane4.setViewportView(jTextAreaDiagnostico);

        jTextAreaComentario.setColumns(20);
        jTextAreaComentario.setRows(5);
        jScrollPane7.setViewportView(jTextAreaComentario);

        jTextAreaExamenPreliminar.setColumns(20);
        jTextAreaExamenPreliminar.setRows(5);
        jScrollPane8.setViewportView(jTextAreaExamenPreliminar);

        jLabelAlergias.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabelAlergias.setText("Alergias");

        jTableAlergias.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"Diacortin 1mg", "1/1/1", "2/1/1", "1440"},
                {"Casdf 2mg", "1/1/1", "2/1/1", null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Medicina", "Inicio", "Fin", "Frecuencia"
            }
        ));
        jScrollPane12.setViewportView(jTableAlergias);

        jLabelDiscapacidades.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabelDiscapacidades.setText("Discapacidades");

        jTableDiscapacidades.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"Diacortin 1mg", "1/1/1", "2/1/1", "1440"},
                {"Casdf 2mg", "1/1/1", "2/1/1", null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Medicina", "Inicio", "Fin", "Frecuencia"
            }
        ));
        jScrollPane13.setViewportView(jTableDiscapacidades);

        jButtonCambiarFormulario.setText("Cambiar Formulario");

        javax.swing.GroupLayout panel7Layout = new javax.swing.GroupLayout(panel7);
        panel7.setLayout(panel7Layout);
        panel7Layout.setHorizontalGroup(
            panel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel7Layout.createSequentialGroup()
                .addGroup(panel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panel7Layout.createSequentialGroup()
                        .addGap(50, 50, 50)
                        .addGroup(panel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(panel7Layout.createSequentialGroup()
                                .addGroup(panel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jLabel4)
                                    .addComponent(jScrollPane8)
                                    .addComponent(jScrollPane9)
                                    .addGroup(panel7Layout.createSequentialGroup()
                                        .addComponent(jLabelTratamiento)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                                    .addComponent(jScrollPane10, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 452, Short.MAX_VALUE)
                                    .addComponent(jScrollPane11))
                                .addGroup(panel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(panel7Layout.createSequentialGroup()
                                        .addGap(62, 62, 62)
                                        .addGroup(panel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(jLabelComentario)
                                            .addComponent(jLabelAlergias)
                                            .addComponent(jLabelDiscapacidades)
                                            .addComponent(jScrollPane12)
                                            .addComponent(jScrollPane4)
                                            .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 474, Short.MAX_VALUE)
                                            .addComponent(jScrollPane13))
                                        .addGap(67, 67, 67)
                                        .addGroup(panel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jButtonCambiarFormulario)
                                            .addComponent(jButtonImprimir)
                                            .addComponent(jButtonPruebas)
                                            .addComponent(buttonFotoCam)
                                            .addComponent(jButtonHistorial)))
                                    .addGroup(panel7Layout.createSequentialGroup()
                                        .addGap(81, 81, 81)
                                        .addComponent(jLabel6))))
                            .addGroup(panel7Layout.createSequentialGroup()
                                .addComponent(PanelDatosPaciente1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(72, 72, 72)
                                .addComponent(TratamientosActuales, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 335, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(panel7Layout.createSequentialGroup()
                        .addGap(368, 368, 368)
                        .addComponent(button_Formulario_Cancelar)
                        .addGap(109, 109, 109)
                        .addComponent(button_Formulario_Guardar)))
                .addContainerGap(2425, Short.MAX_VALUE))
        );
        panel7Layout.setVerticalGroup(
            panel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel7Layout.createSequentialGroup()
                .addGap(31, 31, 31)
                .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(57, 57, 57)
                .addGroup(panel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(PanelDatosPaciente1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(TratamientosActuales, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panel7Layout.createSequentialGroup()
                        .addComponent(jButtonHistorial)
                        .addGap(55, 55, 55)
                        .addComponent(jButtonPruebas)
                        .addGap(88, 88, 88)
                        .addComponent(buttonFotoCam)
                        .addGap(61, 61, 61)
                        .addComponent(jButtonImprimir)
                        .addGap(47, 47, 47)
                        .addComponent(jButtonCambiarFormulario))
                    .addGroup(panel7Layout.createSequentialGroup()
                        .addGroup(panel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(jLabel6))
                        .addGroup(panel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(panel7Layout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panel7Layout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(18, 18, 18)
                        .addGroup(panel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(panel7Layout.createSequentialGroup()
                                .addComponent(jLabelTratamiento)
                                .addGap(23, 23, 23)
                                .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(35, 35, 35)
                                .addComponent(jScrollPane10, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(panel7Layout.createSequentialGroup()
                                .addComponent(jLabelComentario)
                                .addGap(18, 18, 18)
                                .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jLabelAlergias)
                                .addGap(18, 18, 18)
                                .addComponent(jScrollPane12, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGroup(panel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(panel7Layout.createSequentialGroup()
                                .addGap(32, 32, 32)
                                .addComponent(jScrollPane11, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(panel7Layout.createSequentialGroup()
                                .addGap(6, 6, 6)
                                .addComponent(jLabelDiscapacidades)
                                .addGap(18, 18, 18)
                                .addComponent(jScrollPane13, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addGap(68, 68, 68)
                .addGroup(panel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(button_Formulario_Guardar)
                    .addComponent(button_Formulario_Cancelar))
                .addGap(1426, 1426, 1426))
        );

        TratamientosActuales.getAccessibleContext().setAccessibleName("");

        panelFormularioGenerico.setViewportView(panel7);

        add(panelFormularioGenerico, "cardFormularioGenerico");

        buttonMotivoAtras.setText("Atras");

        buttonMotivoGuardar.setText("Guardar");

        PanelDatosCita.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Datos Cita", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Times New Roman", 0, 18))); // NOI18N

        DNIPacienteMotivo.setText("DNI");

        NSSPacienteMotivo.setText("NSS");

        MotivoPacienteMotivo.setText("Motivo");

        FechaPacienteMotivo.setText("Fecha");

        javax.swing.GroupLayout PanelDatosCitaLayout = new javax.swing.GroupLayout(PanelDatosCita);
        PanelDatosCita.setLayout(PanelDatosCitaLayout);
        PanelDatosCitaLayout.setHorizontalGroup(
            PanelDatosCitaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PanelDatosCitaLayout.createSequentialGroup()
                .addGroup(PanelDatosCitaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(DNIPacienteMotivo)
                    .addComponent(NSSPacienteMotivo))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 167, Short.MAX_VALUE)
                .addGroup(PanelDatosCitaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(MotivoPacienteMotivo)
                    .addComponent(FechaPacienteMotivo))
                .addGap(80, 80, 80)
                .addComponent(FotoPacienteMotivo, javax.swing.GroupLayout.PREFERRED_SIZE, 183, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        PanelDatosCitaLayout.setVerticalGroup(
            PanelDatosCitaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(FotoPacienteMotivo, javax.swing.GroupLayout.DEFAULT_SIZE, 261, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PanelDatosCitaLayout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addGroup(PanelDatosCitaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(DNIPacienteMotivo)
                    .addComponent(MotivoPacienteMotivo))
                .addGap(18, 18, 18)
                .addGroup(PanelDatosCitaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(FechaPacienteMotivo, javax.swing.GroupLayout.DEFAULT_SIZE, 34, Short.MAX_VALUE)
                    .addComponent(NSSPacienteMotivo))
                .addGap(150, 150, 150))
        );

        buttonMotivoCambiar.setText("Cambiar motivo");

        javax.swing.GroupLayout panelMotivoLayout = new javax.swing.GroupLayout(panelMotivo);
        panelMotivo.setLayout(panelMotivoLayout);
        panelMotivoLayout.setHorizontalGroup(
            panelMotivoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelMotivoLayout.createSequentialGroup()
                .addGroup(panelMotivoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelMotivoLayout.createSequentialGroup()
                        .addGap(52, 52, 52)
                        .addComponent(buttonMotivoAtras)
                        .addGap(82, 82, 82)
                        .addComponent(buttonMotivoGuardar)
                        .addGap(127, 127, 127)
                        .addComponent(buttonMotivoCambiar))
                    .addGroup(panelMotivoLayout.createSequentialGroup()
                        .addGap(22, 22, 22)
                        .addComponent(PanelDatosCita, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(2286, Short.MAX_VALUE))
        );
        panelMotivoLayout.setVerticalGroup(
            panelMotivoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelMotivoLayout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addComponent(PanelDatosCita, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(panelMotivoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(buttonMotivoAtras)
                    .addComponent(buttonMotivoGuardar)
                    .addComponent(buttonMotivoCambiar))
                .addContainerGap(1167, Short.MAX_VALUE))
        );

        add(panelMotivo, "cardMotivo");

        buttonCambiarMotivoAtras.setText("Atras");

        jScrollPane6.setViewportView(jListCambiarMotivo);

        javax.swing.GroupLayout panelCambiarMotivoLayout = new javax.swing.GroupLayout(panelCambiarMotivo);
        panelCambiarMotivo.setLayout(panelCambiarMotivoLayout);
        panelCambiarMotivoLayout.setHorizontalGroup(
            panelCambiarMotivoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelCambiarMotivoLayout.createSequentialGroup()
                .addGroup(panelCambiarMotivoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelCambiarMotivoLayout.createSequentialGroup()
                        .addGap(97, 97, 97)
                        .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 407, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(panelCambiarMotivoLayout.createSequentialGroup()
                        .addGap(184, 184, 184)
                        .addComponent(buttonCambiarMotivoAtras)))
                .addContainerGap(2307, Short.MAX_VALUE))
        );
        panelCambiarMotivoLayout.setVerticalGroup(
            panelCambiarMotivoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelCambiarMotivoLayout.createSequentialGroup()
                .addGap(43, 43, 43)
                .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 228, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(38, 38, 38)
                .addComponent(buttonCambiarMotivoAtras)
                .addContainerGap(1193, Short.MAX_VALUE))
        );

        add(panelCambiarMotivo, "cardCambiarMotivo");

        tabHistorial.setName("fcb"); // NOI18N

        jListAlergias.setCellRenderer(new DefaultListCellRenderer(){
            @Override
            public Component getListCellRendererComponent(JList list, Object value,
                int index,boolean isSelected, boolean cellHasFocus) {
                Historial historia = (Historial)value;
                setText("Alergia: " + historia.getNombre());

                if (isSelected) {
                    setBackground(Color.LIGHT_GRAY);
                }
                else{
                    setBackground(Color.WHITE);
                }
                return this;

            }
        });
        scrollAlergias.setViewportView(jListAlergias);

        tabHistorial.addTab("Alergias", scrollAlergias);
        tabHistorial.addTab("Curas", scrollCuras);

        javax.swing.GroupLayout panelHistorialLayout = new javax.swing.GroupLayout(panelHistorial);
        panelHistorial.setLayout(panelHistorialLayout);
        panelHistorialLayout.setHorizontalGroup(
            panelHistorialLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelHistorialLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(tabHistorial, javax.swing.GroupLayout.PREFERRED_SIZE, 746, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(2055, Short.MAX_VALUE))
        );
        panelHistorialLayout.setVerticalGroup(
            panelHistorialLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelHistorialLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(tabHistorial, javax.swing.GroupLayout.PREFERRED_SIZE, 512, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(1002, Short.MAX_VALUE))
        );

        tabHistorial.getAccessibleContext().setAccessibleName("");

        add(panelHistorial, "cardHistorial");
    }// </editor-fold>//GEN-END:initComponents

    private void userActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_userActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_userActionPerformed

private void jButtonHistorialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonHistorialActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jButtonHistorialActionPerformed

private void jButtonPruebasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonPruebasActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jButtonPruebasActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Button1;
    private javax.swing.JButton Button3;
    private javax.swing.JButton Button5;
    private javax.swing.JLabel DNIPaciente;
    private javax.swing.JLabel DNIPacienteMotivo;
    private javax.swing.JLabel DireccionPaciente;
    private javax.swing.JLabel EmailPaciente;
    private javax.swing.JLabel FechaPacienteMotivo;
    private javax.swing.JLabel FotoPaciente1;
    private javax.swing.JLabel FotoPacienteMotivo;
    private javax.swing.JLabel MotivoPacienteMotivo;
    private javax.swing.JLabel NSSPaciente;
    private javax.swing.JLabel NSSPacienteMotivo;
    private javax.swing.JLabel NacimientoPaciente;
    private javax.swing.JLabel NombrePaciente;
    private javax.swing.JPanel PanelDatosCita;
    private javax.swing.JPanel PanelDatosPaciente1;
    private javax.swing.JLabel TelefonoPaciente;
    private javax.swing.JPanel TratamientosActuales;
    private javax.swing.JButton buttonCambiarMotivoAtras;
    private javax.swing.JButton buttonExit;
    private javax.swing.JButton buttonFotoCam;
    private javax.swing.JButton buttonLogout;
    private javax.swing.JButton buttonMotivoAtras;
    private javax.swing.JButton buttonMotivoCambiar;
    private javax.swing.JButton buttonMotivoGuardar;
    private javax.swing.JButton button_Formulario_Cancelar;
    private javax.swing.JButton button_Formulario_Guardar;
    private javax.swing.JLabel consultaMedico;
    private javax.swing.JLabel emailMedico;
    private javax.swing.JLabel errorLogin;
    private javax.swing.JLabel etiqueta1;
    private javax.swing.JLabel etiqueta2;
    private javax.swing.JLabel etiqueta3;
    private javax.swing.JLabel fotoMedico;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButtonCambiarFormulario;
    private javax.swing.JButton jButtonHistorial;
    private javax.swing.JButton jButtonImprimir;
    private javax.swing.JButton jButtonPruebas;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabelAlergias;
    private javax.swing.JLabel jLabelComentario;
    private javax.swing.JLabel jLabelDiscapacidades;
    private javax.swing.JLabel jLabelTratamiento;
    private javax.swing.JList jList1;
    private javax.swing.JList jList2;
    private javax.swing.JList jListAlergias;
    private javax.swing.JList jListCambiarMotivo;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane10;
    private javax.swing.JScrollPane jScrollPane11;
    private javax.swing.JScrollPane jScrollPane12;
    private javax.swing.JScrollPane jScrollPane13;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JScrollPane jScrollPane9;
    private javax.swing.JTable jTableAlergias;
    private javax.swing.JTable jTableCuras;
    private javax.swing.JTable jTableDiscapacidades;
    private javax.swing.JTable jTableMedicinas;
    private javax.swing.JTable jTableOtros;
    private javax.swing.JTable jTableTratamientosActuales;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JTextArea jTextAreaComentario;
    private javax.swing.JTextArea jTextAreaDiagnostico;
    private javax.swing.JTextArea jTextAreaExamenPreliminar;
    private javax.swing.JLabel nombreMedico;
    private javax.swing.JPanel panel1;
    private javax.swing.JPanel panel2;
    private javax.swing.JPanel panel4;
    private javax.swing.JPanel panel5;
    private javax.swing.JPanel panel7;
    private javax.swing.JPanel panelCambiarMotivo;
    private javax.swing.JPanel panelCitas;
    private javax.swing.JScrollPane panelFormularioGenerico;
    private javax.swing.JPanel panelHistorial;
    private javax.swing.JPanel panelMedico;
    private javax.swing.JPanel panelMotivo;
    private javax.swing.JPasswordField pass;
    private javax.swing.JScrollPane scrollAlergias;
    private javax.swing.JScrollPane scrollCuras;
    private javax.swing.JTabbedPane tabHistorial;
    private javax.swing.JLabel telefonoMedico;
    private javax.swing.JTextField user;
    // End of variables declaration//GEN-END:variables
    private Histogram histograma ;
    private DefaultListModel listModel;
    private DefaultListModel listModelCitas;
    private DefaultListModel listModelCambiarMotivo;
    private DefaultListModel listModelAlergias;
    
    private DefaultTableModel tableModelTratamientosActuales;
    private DefaultTableModel tableModelCuras;
    private DefaultTableModel tableModelMedicinas;
    private DefaultTableModel tableModelOtros;
    
    // Asociacion de ActionListener  a los botones
    public void addButtonListener(ActionListener aLis){
        buttonMotivoAtras.addActionListener(aLis);
        buttonMotivoGuardar.addActionListener(aLis);
        buttonMotivoCambiar.addActionListener(aLis);
        buttonCambiarMotivoAtras.addActionListener(aLis);
        Button1.addActionListener(aLis);
        Button3.addActionListener(aLis);
        Button5.addActionListener(aLis);
        histograma.addActionListener(aLis);
        jButton2.addActionListener(aLis);
        jButton1.addActionListener(aLis);
        jButton3.addActionListener(aLis);
        buttonExit.addActionListener(aLis);
        buttonLogout.addActionListener(aLis);
        button_Formulario_Cancelar.addActionListener(aLis);
        button_Formulario_Guardar.addActionListener(aLis);
        buttonFotoCam.addActionListener(aLis);
        jButtonHistorial.addActionListener(aLis);
    }
    // Asociacion de MouseAdapter
    public void addMouseListener(MouseAdapter mouseAdapter){
        jList2.addMouseListener(mouseAdapter);
    }
    public void addMouseListenerListaCitas(MouseAdapter mouseAdapter){
        jList1.addMouseListener(mouseAdapter);
    }
    public void addMouseListenerListaCambiarMotivo(MouseAdapter mouseAdapter){
        jListCambiarMotivo.addMouseListener(mouseAdapter);
    }
    public void addMouseListenerListaAlergias(MouseAdapter mouseAdapter){
        jListAlergias.addMouseListener(mouseAdapter);
    }
    
    //*****************************************//
    // Metodos asociados al panel 1 (Logearse) //
    //*****************************************//
    
    // Devuelve el usuario introducido
    public String getUsuario(){
        return user.getText();
    }
    // Devuelve el pass introducido
    public String getPass(){ 
        String password = new String(pass.getPassword());
        return password;
    }
    // Si el usuario o la contraseña muestra mensaje error
    public void setErrorLogin(){ 
        errorLogin.setText("Usuario/Contraseña incorrecta");
    }
    public JButton getButton1(){
        return Button1;
    }
    public JButton getButtonExit(){
        return buttonExit;
    }
    //*****************************************//
    // Metodos asociados al panel 2            //
    //*****************************************//
    public JButton getButtonLogout(){
        return buttonLogout;
    }
    public JButton getButton3(){
        return Button3;
    }
    public JButton getButton5(){
        return Button5;
    }
    public String getList1Value(){
        return jList1.getSelectedValue().toString();
    }
    public void setDatosPersonales(String[] datos){
        URL ruta = getClass().getResource(datos[4]);
        nombreMedico.setText("Nombre: "+datos[0]);
        emailMedico.setText("Email: "+datos[1]);
        consultaMedico.setText("Consulta: "+datos[2]);
        telefonoMedico.setText("Telefono: "+datos[3]);
        fotoMedico.setText("");
        if (ruta != null)
            fotoMedico.setIcon(new ImageIcon(ruta));
    }
    public String getEmailMedico(){
        return emailMedico.getText().substring(7);
    }
    public void setListModelCitas(Map<Integer,PacienteCita> pacientesCita){
        listModelCitas.clear();
        int numCitas= pacientesCita.size();
        for(int i=0;i<numCitas;i++){
            listModelCitas.addElement(pacientesCita.get(i));
        }
    }
    public ListModel getListModelCitas(){
        return listModelCitas;
    }
    public JList getJList1(){
        return jList1;
    }
    
    
    //*********************************************//
    // Metodos asociados al panel Motivo           //
    //*********************************************//
    
    public JButton getButtonMotivoAtras(){
        return buttonMotivoAtras;
    }
    
    public JButton getButtonMotivoCambiar(){
        return buttonMotivoCambiar;
    }
    
    public JButton getButtonMotivoGuardar(){
        return buttonMotivoGuardar;
    }
    
    public void setMotivo(String motivo){
        MotivoPacienteMotivo.setText("Motivo: "+motivo);
    }
    public void setDatosCita(Cita cita){
        DNIPacienteMotivo.setText("DNI: "+cita.getDNI());
        NSSPacienteMotivo.setText("NSS: "+cita.getNSS());
        MotivoPacienteMotivo.setText("Motivo: "+cita.getMotivo());
        FechaPacienteMotivo.setText("Fecha: "+cita.getFecha());
    }
    
    public Cita getDatosCita(){
        Cita cita = new Cita();
        cita.setDNI(DNIPacienteMotivo.getText());
        cita.setNSS(NSSPacienteMotivo.getText());
        cita.setMotivo(MotivoPacienteMotivo.getText());
        cita.setFecha(FechaPacienteMotivo.getText());
        return cita;
    }
    
    //*********************************************//
    // Metodos asociados al panel Cambiar Motivo   //
    //*********************************************//
    
    public JButton getButtonCambiarMotivoAtras(){
        return buttonCambiarMotivoAtras;
    }
      

    
    public void setListModelCambiarMotivo(){
        listModelCambiarMotivo.clear();
        listModelCambiarMotivo.addElement(new TipoFormulario(Tipo.GENERICO));
        listModelCambiarMotivo.addElement(new TipoFormulario(Tipo.CARDIACO));
        listModelCambiarMotivo.addElement(new TipoFormulario(Tipo.ROTURA));
    }
    public ListModel getListModelCambiarMotivo(){
        return listModelCambiarMotivo;
    }
    public JList getJListCambiarMotivo(){
        return jListCambiarMotivo;
    } 
     
    //*****************************************//
    // Metodos asociados al panel 4           //
    //*****************************************//
    public JButton getButton4(){
        return histograma.getJButton4();
    }
    public void configHistograma(Map<String,int[]> hMap){
        histograma.setComboBoxAddItem(hMap);
    }
    public JComboBox getComboBoxHistograma(){
      return histograma.getJComboBox();
    }
    public void dibujarHistograma(){
        histograma.dibujarHistograma();
    }
    //*******************************************//
    // Panel 5: Lector de mail                   //
    //*******************************************//
    public ListModel getListModel(){
        return listModel;
    }
    public JList getJList2(){
        return jList2;
    }
    public JButton getJButton2(){
        return jButton2;
    }
    public JButton getJButton1(){
        return jButton1;
    }
    public JButton getJButton3(){
        return jButton3;
    }
    public JTextArea getJTextArea1(){
        return jTextArea1;
    }
    public void setListModel(Mensaje[] mensajeList){
        listModel.clear();
        for(int i=0;i<mensajeList.length;i++){
            listModel.addElement(mensajeList[i]);
        }
    }
     //*******************************************//
    // Panel 6: Formulario                       //
    //*******************************************//
     public JButton getButton_Formulario_Cancelar(){
        return button_Formulario_Cancelar;
     }    
     public JButton getButton_Formulario_Guardar(){
        return button_Formulario_Guardar;
     }    
     public void setDatosPaciente(String[] datos){
        URL ruta = getClass().getResource(datos[7]);
        DNIPaciente.setText("DNI: "+datos[0]);
        NSSPaciente.setText("NSS: "+datos[1]);
        NombrePaciente.setText("Nombre: "+datos[2]);
      //  HistorialPaciente.setText("Historial: "+datos[3]);
        DireccionPaciente.setText("Dirección: "+datos[4]);
        TelefonoPaciente.setText("Teléfono: "+ datos[5]);
      //  ComentarioPaciente.setText("Comentario: "+datos[6]);
        NacimientoPaciente.setText("Nacimiento: "+datos[8]);
        EmailPaciente.setText("Email: "+datos[9]);
        if (ruta != null)
            FotoPaciente1.setIcon(new ImageIcon(ruta));
    }
    public String getTextDiagnostico(){
        return jTextAreaDiagnostico.getText();
    }
    public String getTextComentario(){
        return jTextAreaComentario.getText();
    }
    public String getTextExamenPreliminar(){
        return jTextAreaExamenPreliminar.getText();
    }
    public JButton getButtonFotaCam(){
        return buttonFotoCam;
    }
    public JButton getButtonHistorial(){
        return jButtonHistorial;
    }
    public void clearTableModelMedicinas(){
        for(int i=0; i<tableModelMedicinas.getRowCount(); i++){
            tableModelMedicinas.removeRow(i);
        }
    }
    
    public void addRowTableModelMedicinas(String medicina, String inicio, String fin, int frecuencia){
        int ultimaFila = tableModelMedicinas.getRowCount();
        tableModelMedicinas.setValueAt(medicina,ultimaFila,0);
        tableModelMedicinas.setValueAt(inicio,ultimaFila , 1);
        tableModelMedicinas.setValueAt(fin,ultimaFila , 2);
        tableModelMedicinas.setValueAt(frecuencia,ultimaFila,3);
    }
    
    public JTable getJTableMedicinas(){
        return jTableMedicinas;
    }
    
    public DefaultTableModel getTableModelMedicinas(){
        return tableModelMedicinas;
    }
    
    public void addRowTableModelTratamientosActuales(String tipo, String nombre, String inicio, String fin, int frecuencia, boolean cancelada, String motivo){
        int ultimaFila = tableModelTratamientosActuales.getRowCount();
        tableModelTratamientosActuales.setValueAt(tipo,ultimaFila,0);
        tableModelTratamientosActuales.setValueAt(nombre,ultimaFila, 1);
        tableModelTratamientosActuales.setValueAt(inicio,ultimaFila, 2);
        tableModelTratamientosActuales.setValueAt(fin,ultimaFila , 3);
        tableModelTratamientosActuales.setValueAt(frecuencia,ultimaFila,4);
        tableModelTratamientosActuales.setValueAt(cancelada,ultimaFila, 5);
        tableModelTratamientosActuales.setValueAt(motivo,ultimaFila,6);
    }
    
    public JTable getJTableTratamientosActuales(){
        return jTableTratamientosActuales;
    }
    
    public DefaultTableModel getTableModelTratamientosActuales(){
        return tableModelTratamientosActuales;
    }
     //*******************************************//
    // Panel Historial                           //
    //*******************************************//
    public void setListModelAlergias(Map<Integer,Historial> historia){
        listModelAlergias.clear();
        int numAlergias= historia.size();
        for(int i=0;i<numAlergias;i++){
            listModelAlergias.addElement(historia.get(i));
        }
    }
    public JList getJListAlergias(){
        return jListAlergias;
    }
    public ListModel getListModelAlergias(){
        return listModelAlergias;
    }
}
